package com.xgkj.diyiketang.task;

import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;
import com.xgkj.diyiketang.http.engine.TaskResultCode;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by windo on 16/6/17.
 */
public class UploadImage extends CouponHttpBaseTask{
    private static final String IMAGE = "image";
    private String mPath;

    public UploadImage(String path) {
        mPath = path;
    }
    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        CouponHttpRequest request = new CouponHttpRequest();
        request.setApiNo(ApiNo.UPLOAD_IMAGE);
        Map<String, String> map = new HashMap<String, String>();
        map.put(IMAGE, mPath);
        request.setFormParam(map);
        addRequest(request);
    }

    @Override
    protected void processResponseData(CouponHttpResponse response) {
        notifyTaskCompleted(TaskResultCode.SUCCESS,response.getBody());
    }
}
